Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

230
Visualizações
Failed to resolve module specifier "three" - Working Three/Wordpress Integration Suddenly Failed

I manage a WordPress website which uses a Three.js animation on the homepage. I built this site months ago and everything had been working perfectly fine - I even showed it to someone a week ago and nothing was amiss. Yesterday, I check the site and find that Three is not loading, and that I have this in the console:

Uncaught TypeError: Failed to resolve module specifier "three". Relative references must start with either "/", "./", or "../".

I don't have a line or even file to reference, the error is logged coming from the first line of the root domain. I want to emphasize that I had changed absolutely nothing about the set-up. I hadn't even updated to WP 5.9 yet. This is how I had originally set things up. Sorry if it's not best practices, but I want to emphasize that it did in fact work fine. Enqueuing animation javascript file and defining its type as "module":

function my_custom_scripts() {
    wp_enqueue_script( 'gsap', 'https://cdnjs.cloudflare.com/ajax/libs/gsap/3.7.0/gsap.min.js', array( 'jquery' ), '', true);
    wp_enqueue_script( 'scrolltrigger', 'https://cdnjs.cloudflare.com/ajax/libs/gsap/3.7.0/ScrollTrigger.min.js', array( 'gsap' ), '', true);
    wp_enqueue_script( 'custom-animations', get_stylesheet_directory_uri() . '/js/animations.js', array( 'gsap' ),'',true );
    
}
add_action( 'wp_enqueue_scripts', 'my_custom_scripts', 15);

add_filter('script_loader_tag','add_type_to_script', 10, 3);
function add_type_to_script($tag, $handle, $source){
    if ('custom-animations' === $handle) {
        $tag = '<script type="module" src="'. $source .'"></script>';
    } 
    return $tag;
}

First lines of "animations.js":

import * as THREE from 'https://cdn.skypack.dev/three@0.137.5/build/three.module.js';
import { GLTFLoader } from "https://threejs.org/examples/jsm/loaders/GLTFLoader.js";
import { DRACOLoader } from 'https://threejs.org/examples/jsm/loaders/DRACOLoader.js';

If there is other relevant code to this problem, please let me know, but I've been pouring over this and tried A) downloading the module file and putting it on my own server and providing a relative path, the same console issue appears (though it did complain with a 404 if the link was invalid, suggesting it did follow it). B) downloading the three.min.js file and loading it before this one, removing the module call entirely and I still get the same console error (even though it's not even being imported as a module). This site has been hosted on Cloudflare, so I did disable that first. Clearing the cache changed nothing, and I have confirmed at every step that I have not been loading a cached version. In the Network tab of Chrome dev tools, the module/file gets loaded into the cache just fine. Somewhere along the way, some file (I wish the console would specify, maybe that is indicative of the problem) fails to attach "Three" as a module and I have no idea why. Any help would be massively appreciated!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I had exact same problem. I uploaded my project on Github a month ago (https://kramzin.github.io/threejs-task/) and since then didn't change a one symbol, but about a week ago it started showing same strange error in console. I found following: "Since r137 using ES6 modules like GLTFLoader in the browser requires an import map. Add the following section right below you canvas."

<script type="importmap">
    {
        "imports": {
            "three": "../master/three.js-master/build/three.module.js"
        }
    }
</script>

The three.js import statement in your scripts.js looks like so then:

import * as THREE from 'three'

https://github.com/Kramzin/threejs-task - Here you can see updated and previous code, after these changes everything started working

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda